package com.gotokeep.gyromousedemo

import android.app.Service
import android.content.Intent
import android.os.IBinder

class ServerService : Service() {

    private lateinit var dataReceiver: DataReceiver

    override fun onBind(intent: Intent?): IBinder? {
        return null
    }

    override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
        if (!this::dataReceiver.isInitialized) {
            dataReceiver = DataReceiver
        }
        return START_STICKY
    }

    override fun onDestroy() {
        super.onDestroy()
        if (this::dataReceiver.isInitialized) {
            dataReceiver.release()
        }
    }
}
